LookupApi
A class for interfacing with the Vecto Lookup API.
Methods:
lookup
async lookup(requestParameters: LookupRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<LookupResponse>
Searches for the nearest vectors to the query in the provided vector space.
Args:
- requestParameters (LookupRequest): Parameters for the lookup request.
vectorSpaceId
: The ID of the vector space to search in (required).modality
: The modality of the query.topK
: The number of top vectors to return.query
: The query vector.ids
: List of specific IDs to search.
- initOverrides (RequestInit or runtime.InitOverrideFunction): Overrides for the request initialization.
Returns:
- Array(LookupResponse): Returns an array of
LookupResult
. EachLookupResult
element contains:id
: indexed data id.similarity
: Lookup search result score.attributes
: Information appended to the indexed data.
- Text
- Image
import { Configuration, LookupApi, LookupRequest } from 'vecto-sdk'
const config = new Configuration({
accessToken: 'your-token'
});
const api = new LookupApi(config);
const textParams: LookupRequest = {
vectorSpaceId: 'your-vector-space-id',
modality: 'TEXT',
topK: 3,
query: 'sample',
};
const responseText = await api.lookup(textParams);
import { Configuration, LookupApi, LookupRequest } from 'vecto-sdk'
import fs from 'fs';
const config = new Configuration({
accessToken: 'your-token'
});
const api = new LookupApi(config);
const fileContent = fs.readFileSync('path/to/your/image.png');
const imageBlob = new Blob([fileContent]);
const imageParams: LookupRequest = {
vectorSpaceId: 'your-vector-space-id',
modality: 'IMAGE',
topK: 3,
query: imageBlob,
};
const responseImage = await api.lookup(imageParams);
lookupWithDynamicAnalogy
async lookupWithDynamicAnalogy(requestParameters: LookupWithDynamicAnalogyRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<LookupResponse>
Gets the word or image analogy by providing the query parameter and the analogy as the start and end parameters. For example: query=cat
, start=dog
, end=puppy
and the expected output would be kitten
.
Args:
- requestParameters (LookupWithDynamicAnalogyRequest): Parameters for the lookup request.
vectorSpaceId
: The ID of the vector space to search in (required).modality
: The modality of the query.topK
: The number of top analogies to return.query
: The query word or image (required).start
: Array of starting points for the analogy (required).end
: Array of end points for the analogy (required).
- initOverrides (RequestInit or runtime.InitOverrideFunction): Overrides for the request initialization.
Returns:
- Array(LookupResponse): Returns an array of
LookupResult
. EachLookupResult
element contains:id
: indexed data id.similarity
: Lookup search result score.attributes
: Information appended to the indexed data.
- Text
- Image
import { Configuration, LookupApi, LookupRequest, LookupWithDynamicAnalogyRequest } from 'vecto-sdk'
const config = new Configuration({
accessToken: 'your-token'
});
const api = new LookupApi(config);
const textParams: LookupRequest = {
vectorSpaceId: 'your-vector-space-id',
modality: 'TEXT',
topK: 3,
query: 'sample',
};
const responseText = await api.lookup(textParams);
const analogyTextParams: LookupWithDynamicAnalogyRequest = {
vectorSpaceId: 'your-vector-space-id',
modality: 'TEXT',
topK: 3,
query: "Man",
start: [new Blob(["King"]), new Blob(["Husband"])],
end: [new Blob(["Queen"]), new Blob(["Wife"])],
};
const analogyResponseText = await api.lookupWithDynamicAnalogy(analogyTextParams);
import { Configuration, LookupApi, LookupRequest, LookupWithDynamicAnalogyRequest } from 'vecto-sdk'
import fs from 'fs';
const config = new Configuration({
accessToken: 'your-token'
});
const api = new LookupApi(config);
const fileContent = fs.readFileSync('path/to/your/image.png');
const imageBlob = new Blob([fileContent]);
const imageParams: LookupRequest = {
vectorSpaceId: 'your-vector-space-id',
modality: 'IMAGE',
topK: 3,
query: imageBlob,
};
const responseImage = await api.lookup(imageParams);
const analogyImageParams: LookupWithDynamicAnalogyRequest = {
vectorSpaceId: 'your-vector-space-id',
modality: 'IMAGE',
topK: 3,
query: imageBlob,
start: [imageBlob],
end: [imageBlob]
};
const analogyResponseImage = await api.lookupWithDynamicAnalogy(analogyImageParams);